home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_11_05
/
1105104a
< prev
next >
Wrap
Text File
|
1993-03-07
|
586b
|
23 lines
/* stack.h: Macros for a stack -
*
* A simple-minded stack mechanism. The user's
* program must define the following in the scope
* where they are used:
*
* MAXSTACK The dimension of the stack
* size_t stkptr_ = 0; The stack pointer
* T stk_[MAXSTACK]; The stack: an array of type T
*
* Execution aborts if the stack overflows or
* underflows.
*/
#include <assert.h>
/* Stack operations: */
#define PUSH(x) \
(assert(stkptr_ < MAXSTACK), stk_[stkptr_++] = (x))
#define POP() \
(assert(stkptr_ > 0), stk_[--stkptr_])